using GEM.Application.Contracts.Jwt;
using GEM.Application.Repositories;
using GEM.Application.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace GEM.Application;
/// <summary>
/// 应用层的依赖注入扩展类
/// </summary>
public static class ServicesCollectionExtenstion
{
    public static IServiceCollection AddApplication(this IServiceCollection services, IConfiguration configuration)
    {
        //注册 登录注册服务
        services.AddScoped(typeof(AuthService));

        //注册 用户服务
        services.AddScoped<IUserService, UserService>();

        //注册 角色服务
        services.AddScoped<IRoleService, RoleService>();

        //注册 权限服务
        services.AddScoped<IPermissionService, PermissionService>();

        //注册 文件服务
        services.AddScoped<FileService>();

        // 注册 JwtSettings 配置，供后续服务通过 IOptions<JwtSettings> 注入
        services.Configure<JwtSettings>(configuration.GetSection("Jwt"));

        return services;
    }
}